package com.iot.system.service.impl;

import java.util.List;
import com.iot.common.utils.DateUtils;
import com.iot.system.domain.LineHourEnergyInfo;
import com.iot.system.mapper.LineHourEnergyInfoMapper;
import com.iot.system.service.ILineHourEnergyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 产线小时能耗Service业务层处理
 * 
 * @author iot
 * @date 2025-02-12
 */
@Service
public class LineHourEnergyInfoServiceImpl implements ILineHourEnergyInfoService
{
    @Autowired
    private LineHourEnergyInfoMapper lineHourEnergyInfoMapper;

    /**
     * 查询产线小时能耗
     * 
     * @param id 产线小时能耗主键
     * @return 产线小时能耗
     */
    @Override
    public LineHourEnergyInfo selectLineHourEnergyInfoById(Long id)
    {
        return lineHourEnergyInfoMapper.selectLineHourEnergyInfoById(id);
    }

    /**
     * 查询产线小时能耗列表
     * 
     * @param lineHourEnergyInfo 产线小时能耗
     * @return 产线小时能耗
     */
    @Override
    public List<LineHourEnergyInfo> selectLineHourEnergyInfoList(LineHourEnergyInfo lineHourEnergyInfo)
    {
        return lineHourEnergyInfoMapper.selectLineHourEnergyInfoList(lineHourEnergyInfo);
    }

    /**
     * 新增产线小时能耗
     * 
     * @param lineHourEnergyInfo 产线小时能耗
     * @return 结果
     */
    @Override
    public int insertLineHourEnergyInfo(LineHourEnergyInfo lineHourEnergyInfo)
    {
        lineHourEnergyInfo.setCreateTime(DateUtils.getNowDate());
        return lineHourEnergyInfoMapper.insertLineHourEnergyInfo(lineHourEnergyInfo);
    }

    /**
     * 修改产线小时能耗
     * 
     * @param lineHourEnergyInfo 产线小时能耗
     * @return 结果
     */
    @Override
    public int updateLineHourEnergyInfo(LineHourEnergyInfo lineHourEnergyInfo)
    {
        return lineHourEnergyInfoMapper.updateLineHourEnergyInfo(lineHourEnergyInfo);
    }

    /**
     * 批量删除产线小时能耗
     * 
     * @param ids 需要删除的产线小时能耗主键
     * @return 结果
     */
    @Override
    public int deleteLineHourEnergyInfoByIds(Long[] ids)
    {
        return lineHourEnergyInfoMapper.deleteLineHourEnergyInfoByIds(ids);
    }

    /**
     * 删除产线小时能耗信息
     * 
     * @param id 产线小时能耗主键
     * @return 结果
     */
    @Override
    public int deleteLineHourEnergyInfoById(Long id)
    {
        return lineHourEnergyInfoMapper.deleteLineHourEnergyInfoById(id);
    }

    @Override
    public Boolean judgmentLineHourEnergy(LineHourEnergyInfo lineHourEnergyInfo) {
        if (lineHourEnergyInfo.getLineId() != null && lineHourEnergyInfo.getLineTime() != null) {
            int i = lineHourEnergyInfoMapper.judgmentLineHourEnergy(lineHourEnergyInfo);
            if (i>0){
                return false;
            }
        }
        return true;
    }
}
